from access.core.utterancepattern import UtterancePattern
import unittest

class UtterancePatternTest(unittest.TestCase):
  def testConstruction (self):
    value_info_pattern = UtterancePattern(value_pattern = 'pat',
                                                  snippet_ID_pattern = 'ID')
    self.assertEqual(value_info_pattern.value_pattern,
                     'pat',
                     'Utterance pattern field not set correctly.')
    self.assertEqual(value_info_pattern.snippet_ID_pattern,
                     'ID',
                     'Snippet ID pattern field not set correctly.')

  def testConstructionWithContext (self):
    value_info_pattern = UtterancePattern(value_pattern = 'pat',
                                                  snippet_ID_pattern = 'ID',
                                                  test = ['a'])
    self.assertEqual(value_info_pattern.value_pattern,
                     'pat',
                     'Utterance pattern field not set correctly.')
    self.assertEqual(value_info_pattern.snippet_ID_pattern,
                     'ID',
                     'Snippet ID pattern field not set correctly.')
    self.assertIn('test',
                  value_info_pattern.context, 
                  'Pattern context is missing a key.')
    self.assertIn('a',
                  value_info_pattern.context['test'],
                  'Pattern context has incorrect data.')
